import fetch from '@/utils/fetch';
import store from '@/store';

//获取验证码
export function GetValidateCode(uuid) {
  return fetch({
    url: '/api/auth/code/index?t=' + (new Date()).getTime() + "&uuid=" + uuid,
    method: 'get'
  });
}

//用户登录
export function loginByPassword(userInfo) {
  const login_name = userInfo.login_name.trim();
  const data = {
    system_id: store.getters.system_id,
    login_name,
    login_password: userInfo.login_password,
    sRand: userInfo.sRand,
    uuid: userInfo.uuid
  };
  return fetch({
    url: '/api/auth/jwt/token',
    method: 'post',
    data
  });
}

//退出登录
export function logout(token) {
  return fetch({
    url: '/api/auth/jwt/invalid',
    method: 'post',
    params: {token}
  });
}

//获取用户信息
export function getInfo(token) {
  return fetch({
    url: '/api/auth/front/info',
    method: 'post',
    params: {token}
  });
}
